#ifndef TIMECOUNTER_H
#define TIMECOUNTER_H

#include <QString>

class TimeCounter{

    unsigned int time = 0;

public:

    void increase(){
        time++;
    }

    void set_time(unsigned int t){
        time = t;
    };

    unsigned int to_uint(){
        return time;
    }

    unsigned int to_hour()
    {
        return time/3600;
    }

    unsigned int to_minute()
    {
        return time/60%60;
    }

    unsigned int to_second()
    {
        return time%60;
    }

    unsigned int get_interval(int pre){
        return time-pre;
    }

    QString to_str(){
        unsigned int hour = to_hour();
        unsigned int minute = to_minute();
        unsigned int second = to_second();

        QString str = "";

        if(hour/10)
            str += QString::number(hour)+QString(':');
        else
            str += QString('0')+QString::number(hour)+QString(':');

        if(minute/10)
            str += QString::number(minute)+QString(':');
        else
            str += QString('0')+QString::number(minute)+QString(':');

        if(second/10)
            str += QString::number(second);
        else
            str += QString('0')+QString::number(second);

        return str;
    }

    QString to_str_MMSS(){
        unsigned int minute = to_minute();
        unsigned int second = to_second();

        QString str = "";

        if(minute/10)
            str += QString::number(minute)+QString(':');
        else
            str += QString('0')+QString::number(minute)+QString(':');

        if(second/10)
            str += QString::number(second);
        else
            str += QString('0')+QString::number(second);

        return str;
    }


};

#endif // TIMECOUNTER_H
